import 'package:xinxuan/vo/common_vo/common_blindbox_packages_vo.dart';
import 'package:xinxuan/vo/common_vo/common_pagination_vo.dart';

class BlindBoxOrderListVo {

  List<BlindBoxOrderItem>? data;
  BlindBoxOrderMeta? meta;

  BlindBoxOrderListVo({this.data, this.meta});

  BlindBoxOrderListVo.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = <BlindBoxOrderItem>[];
      json['data'].forEach((v) {
        data!.add(new BlindBoxOrderItem.fromJson(v));
      });
    }
    meta = json['meta'] != null ? new BlindBoxOrderMeta.fromJson(json['meta']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    if (this.meta != null) {
      data['meta'] = this.meta!.toJson();
    }
    return data;
  }
}

class BlindBoxOrderItem {
  int? id;
  String? orderSn;
  int? payStatus;
  int? status;
  String? statusStr;
  int? source;
  String? payableAmount;
  String? paidAmount;
  String? totalAmount;
  String? createdAt;
  String? updatedAt;
  String? voucherCode;
  List<CommonBlindBoxPackagesVo>? packages;
  Lottery? lottery;
  int? type;

  BlindBoxOrderItem(
      {this.id,
      this.orderSn,
      this.payStatus,
      this.status,
      this.statusStr,
      this.source,
      this.payableAmount,
      this.paidAmount,
      this.totalAmount,
      this.createdAt,
      this.updatedAt,
      this.packages,
      this.voucherCode,
      this.lottery,
      this.type});

  BlindBoxOrderItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    orderSn = json['order_sn'];
    payStatus = json['pay_status'];
    status = json['status'];
    statusStr = json['status_str'];
    source = json['source'];
    payableAmount = json['payable_amount'];
    paidAmount = json['paid_amount'];
    totalAmount = json['total_amount'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    voucherCode = json['voucher_code'];
    type = json['type'];
    if (json['packages'] != null) {
      packages = <CommonBlindBoxPackagesVo>[];
      json['packages'].forEach((v) {
        packages!.add(new CommonBlindBoxPackagesVo.fromJson(v));
      });
    }
    lottery =
        json['lottery'] != null ? new Lottery.fromJson(json['lottery']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['order_sn'] = this.orderSn;
    data['pay_status'] = this.payStatus;
    data['status'] = this.status;
    data['status_str'] = this.statusStr;
    data['source'] = this.source;
    data['payable_amount'] = this.payableAmount;
    data['paid_amount'] = this.paidAmount;
    data['total_amount'] = this.totalAmount;
    data['created_at'] = this.createdAt;
    data['updated_at'] = this.updatedAt;
    data['voucher_code'] = this.voucherCode;
    data['type'] = this.type;
    if (this.packages != null) {
      data['packages'] = this.packages!.map((v) => v.toJson()).toList();
    }
    if (this.lottery != null) {
      data['lottery'] = this.lottery!.toJson();
    }
    return data;
  }
}

class BlindBoxOrderMeta {
  CommonPagination? pagination;

  BlindBoxOrderMeta({this.pagination});

  BlindBoxOrderMeta.fromJson(Map<String, dynamic> json) {
    pagination = json['pagination'] != null
        ? new CommonPagination.fromJson(json['pagination'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.pagination != null) {
      data['pagination'] = this.pagination!.toJson();
    }
    return data;
  }
}

class Lottery {
  int? packageId;
  int? productId;
  int? status;
  Product? product;

  Lottery({this.packageId, this.productId, this.status, this.product});

  Lottery.fromJson(Map<String, dynamic> json) {
    packageId = json['package_id'];
    productId = json['product_id'];
    status = json['status'];
    product =
        json['product'] != null ? new Product.fromJson(json['product']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['package_id'] = this.packageId;
    data['product_id'] = this.productId;
    data['status'] = this.status;
    if (this.product != null) {
      data['product'] = this.product!.toJson();
    }
    return data;
  }
}

class Product {
  String? image;
  String? title;
  int? type;

  Product({this.image, this.title, this.type});

  Product.fromJson(Map<String, dynamic> json) {
    image = json['image'];
    title = json['title'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['image'] = this.image;
    data['title'] = this.title;
    data['type'] = this.type;
    return data;
  }
}